/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cellstore.gui;

import java.util.ArrayList;
import org.cellstore.controlador.CellStoreController;
import org.cellstore.gui.model.Columna;
import org.cellstore.gui.model.Modelo;
import org.starcell.spring.Spring;

/**
 *
 * @author PPATOCHE
 */
public class IFMantenimiento extends javax.swing.JInternalFrame {

    /**
     * Creates new form IFMantenimiento
     */
    private Modelo modelo;
    private CellStoreController cellStoreController;

    public IFMantenimiento() {
        cellStoreController = Spring.getInstance().getController();
        cargarColumnas();  
        cargarDatos();
        initComponents();        
    }

    private  void cargarColumnas(){
        ArrayList<Columna> listaColumnas = new ArrayList<Columna>();
//        listaColumnas.add(new Columna("A", "campoa", Integer.class, false, 100, 50, null));     
        modelo = new Modelo(listaColumnas);
    }
    
    private void cargarDatos(){        
    }
    
    private void setModoEdicion(boolean editable){
        txtAbreviatura.setEnabled(true);
        txtBusqueda.setEnabled(true);
        txtDescripcion.setEnabled(true);
        txtId.setEnabled(true);
        txtValor.setEnabled(true);
    }
    
    private void limpiarDatos(){
        txtAbreviatura.setText("");
        txtBusqueda.setText("");
        txtDescripcion.setText("");
        txtId.setText("");
        txtValor.setText("");
    }
    
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        pPrincipal = new javax.swing.JPanel();
        pNorte = new javax.swing.JPanel();
        pControles = new javax.swing.JPanel();
        btnGuarda = new javax.swing.JButton();
        btnLimpia = new javax.swing.JButton();
        btnAnula = new javax.swing.JButton();
        pCampos = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtId = new org.palituxd.tools.swing.CTextField();
        txtValor = new org.palituxd.tools.swing.CTextField();
        txtAbreviatura = new org.palituxd.tools.swing.CTextField();
        txtDescripcion = new org.palituxd.tools.swing.CTextField();
        jPanel2 = new javax.swing.JPanel();
        btnCargaImagen = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        pCentro = new javax.swing.JPanel();
        pBuscar = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        cbBusqueda = new javax.swing.JComboBox();
        txtBusqueda = new org.palituxd.tools.swing.CTextField();
        btnBusqueda = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbDatos = new javax.swing.JTable();
        pSur = new javax.swing.JPanel();
        btnSalida = new javax.swing.JButton();

        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("[Mantenimiento]");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Application-Default-Orange-16.png"))); // NOI18N
        setMinimumSize(new java.awt.Dimension(410, 370));
        setNormalBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setPreferredSize(new java.awt.Dimension(410, 370));
        getContentPane().setLayout(new java.awt.GridBagLayout());

        pPrincipal.setPreferredSize(new java.awt.Dimension(200, 448));
        pPrincipal.setLayout(new java.awt.BorderLayout(0, 5));

        pNorte.setLayout(new java.awt.BorderLayout(10, 0));

        pControles.setLayout(new java.awt.GridBagLayout());

        btnGuarda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Document-Save-16.png"))); // NOI18N
        btnGuarda.setText("Guardar");
        btnGuarda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0);
        pControles.add(btnGuarda, gridBagConstraints);

        btnLimpia.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Edit-Clear-16.png"))); // NOI18N
        btnLimpia.setText("Limpriar");
        btnLimpia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.ipadx = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0);
        pControles.add(btnLimpia, gridBagConstraints);

        btnAnula.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Edit-Delete-16.png"))); // NOI18N
        btnAnula.setText("Anular");
        btnAnula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnulaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.ipadx = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0);
        pControles.add(btnAnula, gridBagConstraints);

        pNorte.add(pControles, java.awt.BorderLayout.EAST);

        pCampos.setLayout(new java.awt.BorderLayout());

        jLabel3.setText("Id");

        jLabel4.setText("Valor");

        jLabel5.setText("Descripción");

        jLabel6.setText("Abreviatura");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGap(51, 51, 51)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtId, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
                            .addComponent(txtValor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(txtAbreviatura, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(12, 12, 12)
                        .addComponent(jLabel4))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(9, 9, 9)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtAbreviatura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pCampos.add(jPanel1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        btnCargaImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Insert-Image-16.png"))); // NOI18N
        btnCargaImagen.setMaximumSize(new java.awt.Dimension(25, 25));
        btnCargaImagen.setMinimumSize(new java.awt.Dimension(25, 25));
        btnCargaImagen.setPreferredSize(new java.awt.Dimension(25, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        jPanel2.add(btnCargaImagen, gridBagConstraints);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        jLabel2.setPreferredSize(new java.awt.Dimension(80, 100));
        jPanel3.add(jLabel2);

        jPanel2.add(jPanel3, new java.awt.GridBagConstraints());

        pCampos.add(jPanel2, java.awt.BorderLayout.EAST);

        pNorte.add(pCampos, java.awt.BorderLayout.CENTER);

        pPrincipal.add(pNorte, java.awt.BorderLayout.NORTH);

        pCentro.setLayout(new java.awt.BorderLayout());

        jLabel1.setText("Buscar");
        pBuscar.add(jLabel1);

        cbBusqueda.setModel(modelo.getDefaultComboBoxModel());
        cbBusqueda.setMinimumSize(new java.awt.Dimension(51, 25));
        cbBusqueda.setPreferredSize(new java.awt.Dimension(100, 20));
        pBuscar.add(cbBusqueda);

        txtBusqueda.setPreferredSize(new java.awt.Dimension(200, 20));
        txtBusqueda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtBusquedaActionPerformed(evt);
            }
        });
        pBuscar.add(txtBusqueda);

        btnBusqueda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Edit-Find-16.png"))); // NOI18N
        btnBusqueda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBusquedaActionPerformed(evt);
            }
        });
        pBuscar.add(btnBusqueda);

        pCentro.add(pBuscar, java.awt.BorderLayout.PAGE_START);

        tbDatos.setAutoCreateRowSorter(true);
        tbDatos.setModel(modelo.getDefaultTableModel());
        tbDatos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        modelo.dimensionarTabla(tbDatos);
        tbDatos.getTableHeader().setReorderingAllowed(false);
        tbDatos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbDatosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbDatos);

        pCentro.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        pPrincipal.add(pCentro, java.awt.BorderLayout.CENTER);

        pSur.setLayout(new java.awt.BorderLayout());

        btnSalida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Gnome-Window-Close-16.png"))); // NOI18N
        btnSalida.setText("Cerrar");
        btnSalida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalidaActionPerformed(evt);
            }
        });
        pSur.add(btnSalida, java.awt.BorderLayout.EAST);

        pPrincipal.add(pSur, java.awt.BorderLayout.PAGE_END);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        getContentPane().add(pPrincipal, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSalidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalidaActionPerformed
        this.setVisible(false);
        
    }//GEN-LAST:event_btnSalidaActionPerformed

    private void btnGuardaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardaActionPerformed

    }//GEN-LAST:event_btnGuardaActionPerformed

    private void btnBusquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBusquedaActionPerformed
        
    }//GEN-LAST:event_btnBusquedaActionPerformed

    private void btnLimpiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiaActionPerformed
        limpiarDatos();
        txtValor.transferFocus();
    }//GEN-LAST:event_btnLimpiaActionPerformed

    private void btnAnulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnulaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAnulaActionPerformed

    private void tbDatosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbDatosMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_tbDatosMouseClicked

    private void txtBusquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBusquedaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtBusquedaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAnula;
    private javax.swing.JButton btnBusqueda;
    private javax.swing.JButton btnCargaImagen;
    private javax.swing.JButton btnGuarda;
    private javax.swing.JButton btnLimpia;
    private javax.swing.JButton btnSalida;
    private javax.swing.JComboBox cbBusqueda;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel pBuscar;
    private javax.swing.JPanel pCampos;
    private javax.swing.JPanel pCentro;
    private javax.swing.JPanel pControles;
    private javax.swing.JPanel pNorte;
    private javax.swing.JPanel pPrincipal;
    private javax.swing.JPanel pSur;
    private javax.swing.JTable tbDatos;
    private org.palituxd.tools.swing.CTextField txtAbreviatura;
    private org.palituxd.tools.swing.CTextField txtBusqueda;
    private org.palituxd.tools.swing.CTextField txtDescripcion;
    private org.palituxd.tools.swing.CTextField txtId;
    private org.palituxd.tools.swing.CTextField txtValor;
    // End of variables declaration//GEN-END:variables
}
